<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<?php echo form_tag_for($form, '@template') ?>
<table id="templates_form">
    <tfoot>
        <tr>
            <td colspan="2">
                <input type="submit" value="Save & Next" />
            </td>
        </tr>
    </tfoot>
    <tbody>
        <?php echo $form->renderGlobalErrors() ?>
        <tr>
            <th><?php echo $form['name']->renderLabel() ?></th>
            <td>
                <?php echo $form['name']->renderError() ?>
                <?php echo $form['name'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['language']->renderLabel() ?></th>
            <td>
                <?php echo $form['language']->renderError() ?>
                <?php echo $form['language'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['country']->renderLabel() ?></th>
            <td>
                <?php echo $form['country']->renderError() ?>
                <?php echo $form['country'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['sender_name']->renderLabel() ?></th>
            <td>
                <?php echo $form['sender_name']->renderError() ?>
                <?php echo $form['sender_name'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['sender_address']->renderLabel() ?></th>
            <td>
                <?php echo $form['sender_address']->renderError() ?>
                <?php echo $form['sender_address'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['subject']->renderLabel() ?></th>
            <td>
                <?php echo $form['subject']->renderError() ?>
                <?php echo $form['subject'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['body_txt']->renderLabel() ?></th>
            <td>
                <?php echo $form['body_txt']->renderError() ?>
                <?php echo $form['body_txt'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['body_html']->renderLabel() ?></th>
            <td>
                <?php echo $form['body_html']->renderError() ?>
                <?php echo $form['body_html'] ?>
                <script type="text/javascript" src="<?php echo public_path("/ckeditor/ckeditor.js") ?>"></script>
                <script type="text/javascript" src="<?php echo public_path("/ckeditor/adapters/jquery.js") ?>"></script>
                <script type="text/javascript">$('#template_body_html').ckeditor();</script>


                or insert Template URL: <input id="templateurl" type="text" name="templateurl">
                <a onclick="{
                    var data = $.get('<?php echo url_for('@curltemplate') . '?url='; ?>' + $('#templateurl').val(),function(data){
                        $( '#template_body_html' ).val(data ) ;
                    });

                }
                   ">Load template</a>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['cc']->renderLabel() ?></th>
            <td>
                <?php echo $form['cc']->renderError() ?>
                <?php echo $form['cc'] ?>
            </td>
        </tr>
        <tr>
            <th><?php echo $form['bcc']->renderLabel() ?></th>
            <td>
                <?php echo $form['bcc']->renderError() ?>
                <?php echo $form['bcc'] ?>
            </td>
        </tr>
        <tr>
            <?php echo $form->renderHiddenFields() ?>
        </tr>

    </tbody>
</table>
</form>